from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
import base64
import json

# 生成 RSA 密钥对
key = RSA.generate(4096)

# 导出公钥和私钥
private_key = key.export_key()
public_key = key.publickey().export_key()

# 将公钥和私钥进行 Base64 编码
private_key_b64 = base64.b64encode(private_key).decode('utf-8')
public_key_b64 = base64.b64encode(public_key).decode('utf-8')

# 将 Base64 编码的密钥存储在代码中
print("Private Key (Base64):", private_key_b64)
print("Public Key (Base64):", public_key_b64)